home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / mac / bib.hqx / Bib Stack / card_9293.txt < prev    next >
Text File  |  1989-12-05  |  11KB  |  327 lines

  1. -- card: 9293 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 4000
  4. -- background id: 3544
  5. -- name: 
  6.  
  7.  
  8. -- part 2 (button)
  9. -- low flags: 00
  10. -- high flags: 8003
  11. -- rect: left=254 top=70 right=94 bottom=427
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Make Distribution Stack
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   global firstRefCard, cardList
  23.  
  24.   answer "This will destroy your Bibliography Data!!" with "Continue" or "Stop"
  25.   if it is "Stop" then exit mouseUp
  26.   answer "Are you quite sure you want to do this?" with Yes or No
  27.   if it is "No" then exit mouseUp
  28.  
  29.   put the number of this card into origCard
  30.  
  31.   set lockScreen to true
  32.   put the number of lines in cardList into maxBkgndNum
  33.   repeat with bkgndCount = 1 to maxBkgndNum
  34.     put line bkgndCount of cardList into bName
  35.     go to bkgnd bName
  36.     put the number of cards of this background into numCards
  37.     repeat with cardToDelete = 2 to numCards
  38.       go to card 2 of bkgnd bName
  39.       put "Deleting Card " & cardToDelete & " of " & numCards & " from bkgnd " & line bkgndCount of cardList
  40.       doMenu "Delete Card"
  41.     end repeat
  42.   end repeat
  43.  
  44.   -- Hide the dangerous buttons on this card.
  45.   go to card origCard
  46.   set lockScreen to false
  47.   set the rect of button "Dump Bkgnd Field Data" to 27,67,187,92
  48.   set the rect of button "Remake Bkgnd Fields" to 25,107,182,132
  49.   set the rect of button "Make Distribution Stack" to 254,70,427,94
  50.  
  51.   -- Make the help fields unchangable.
  52.   go to first card of background Help
  53.   repeat while the short name of this background is "Help"
  54.     set the locktext of field Topic to true
  55.     set the lockText of card field help to true
  56.     if the style of card field help is "scrolling" then
  57.       set the scroll of card field help to 0
  58.     end if
  59.     go to next card
  60.   end repeat
  61.  
  62.   -- Make the non-bibliography cards undeletable.
  63.   go to card 1
  64.   repeat with x = 1 to firstRefCard-1
  65.     set the cantDelete of this card to true
  66.     go to next card
  67.   end repeat
  68.  
  69.   -- Get rid of stray buttons on the first card.
  70.   go to card 1
  71.   select card button "Developer Stack"
  72.   doMenu "Clear Button"
  73.   select card button "foobar"
  74.   doMenu "Clear Button"
  75.   choose browse tool
  76.  
  77. end mouseUp
  78.  
  79.  
  80.  
  81. -- part 3 (button)
  82. -- low flags: 00
  83. -- high flags: 8003
  84. -- rect: left=27 top=67 right=92 bottom=187
  85. -- title width / last selected line: 0
  86. -- icon id / first selected line: 0 / 0
  87. -- text alignment: 1
  88. -- font id: 0
  89. -- text size: 12
  90. -- style flags: 0
  91. -- line height: 16
  92. -- part name: Dump Bkgnd Field Data
  93. ----- HyperTalk script -----
  94. on mouseUp
  95.   global cardList, dumpFile
  96.  
  97.   set cursor to 4
  98.   push card
  99.   set lockscreen to true
  100.  
  101.   -- Make a list of items for the xcmd
  102.   put cardlist into tempList
  103.   -- Convert returns to commas
  104.   repeat with x = 1 to length of tempList
  105.     if char x of tempList = return then
  106.       put "," into char x of tempList
  107.     end if
  108.   end repeat
  109.   put "Pick the backgrounds to dump."
  110.   DoList "Dump","Cancel", tempList, ONE
  111.   put empty into message
  112.   hide message
  113.  
  114.   if the result is empty then exit mouseUp
  115.   put item 2 of the result into bkgndName
  116.  
  117.   -- Select a file to dump to
  118.   put NewFileName("Save dump to",dumpFile) into temp
  119.   put empty into message
  120.   hide message
  121.   if temp is empty then exit mouseUp
  122.   set cursor to 4
  123.   put temp into dumpFile
  124.   open file dumpFile
  125.  
  126.   go to bkgnd bkgndName
  127.   put the number of bkgnd fields into numFields
  128.  
  129.   repeat with x = 1 to numFields
  130.  
  131.     write "bkgnd" to file dumpFile
  132.     write tab & the short name of field x to file dumpFile
  133.     write tab & the location of field x to file dumpFile
  134.     write tab & the lockText of field x to file dumpFile
  135.     write tab & the rectangle of field x to file dumpFile
  136.     write tab & the showlines of field x to file dumpFile
  137.     write tab & the style of field x to file dumpFile
  138.     write tab & the textAlign of field x to file dumpFile
  139.     write tab & the textFont of field x to file dumpFile
  140.     write tab & the textHeight of field x to file dumpFile
  141.     write tab & the textSize of field x to file dumpFile
  142.     write tab & the visible of field x to file dumpFile
  143.     write tab & the wideMargins of field x to file dumpFile
  144.     write tab & the script of field x to file dumpFile
  145.     write tab to file dumpFile
  146.  
  147.     write return to file dumpFile
  148.  
  149.   end repeat
  150.  
  151.   close file dumpFile
  152.  
  153.   -- save the file name
  154.   put LastPathComponent(dumpFile) into dumpFile
  155.   hide message
  156.   pop card
  157.  
  158. end mouseUp
  159.  
  160.  
  161.  
  162. -- part 4 (button)
  163. -- low flags: 00
  164. -- high flags: 8003
  165. -- rect: left=25 top=107 right=132 bottom=182
  166. -- title width / last selected line: 0
  167. -- icon id / first selected line: 0 / 0
  168. -- text alignment: 1
  169. -- font id: 0
  170. -- text size: 12
  171. -- style flags: 0
  172. -- line height: 16
  173. -- part name: Remake Bkgnd Fields
  174. ----- HyperTalk script -----
  175. on mouseUp
  176.   global cardList, dumpFile
  177.  
  178.   set cursor to 4
  179.   push card
  180.   set lockscreen to true
  181.  
  182.   -- Make a list of items for the xcmd
  183.   put cardlist into tempList
  184.   -- Convert returns to commas
  185.   repeat with x = 1 to length of tempList
  186.     if char x of tempList = return then
  187.       put "," into char x of tempList
  188.     end if
  189.   end repeat
  190.   put "Pick the background to remake."
  191.   DoList "Remake","Cancel", tempList, ONE
  192.  
  193.   if the result is empty then
  194.     put empty into message
  195.     hide message
  196.     exit mouseUp
  197.   end if
  198.   put item 2 of the result into bkgndName
  199.  
  200.   -- Select a file to open
  201.   put "Pick the file with the field information."
  202.   put FileName("TEXT") into temp
  203.   put empty into message
  204.   hide message
  205.   if temp is empty then exit mouseUp
  206.   set cursor to 4
  207.   put temp into dumpFile
  208.   open file dumpFile
  209.  
  210.   go to bkgnd bkgndName
  211.  
  212.   -- delete all the old fields
  213.   put the number of bkgnd fields into numFields
  214.  
  215.   repeat with x = 1 to numFields
  216.  
  217.     select bkgnd field 1
  218.     doMenu "Clear Field"
  219.  
  220.   end repeat
  221.  
  222.   doMenu "Background"
  223.   repeat while  true
  224.  
  225.     read from file dumpFile until tab  -- this field says card or bkgnd
  226.     put it into fieldType
  227.     if fieldType is empty or fieldType is return then exit repeat
  228.  
  229.     play "harpsichord" "Ct6"
  230.  
  231.     -- Switch to card, as opposed to bkgnd.
  232.     if fieldType is "card" then set editBkgnd to false
  233.  
  234.     doMenu "New Field"
  235.     put the number of bkgnd fields into x
  236.  
  237.     set the  name of bkgnd field x to readField(dumpFile)
  238.  
  239.     put readField(dumpFile) into temp
  240.     set loc of bkgnd field x to temp
  241.  
  242.     set the lockText of bkgnd field x to readField(dumpFile)
  243.  
  244.     put readField(dumpFile) into temp
  245.     set the rectangle of field x to temp
  246.  
  247.     set the showlines of field x to readField(dumpFile)
  248.     set the style of field x to readField(dumpFile)
  249.     set the textAlign of field x to readField(dumpFile)
  250.     set the textFont of field x to readField(dumpFile)
  251.     set the textHeight of field x to readField(dumpFile)
  252.     set the textSize of field x to readField(dumpFile)
  253.     set the visible of field x to readField(dumpFile)
  254.     set the wideMargins of field x to readField(dumpFile)
  255.     set the script of field x to readField(dumpFile)
  256.  
  257.     read from file dumpFile until return
  258.  
  259.     if fieldType is "card" then set editBkgnd to true
  260.  
  261.   end repeat
  262.  
  263.   close file dumpFile
  264.  
  265.   -- save the file name
  266.   put LastPathComponent(dumpFile) into dumpFile
  267.   hide message
  268.   pop card
  269.   choose browse tool
  270.   put "Remade fields on background " & bkgndName
  271.   beep
  272.  
  273. end mouseUp
  274.  
  275.  
  276.  
  277. -- part 1 (field)
  278. -- low flags: 01
  279. -- high flags: 0007
  280. -- rect: left=7 top=59 right=286 bottom=504
  281. -- title width / last selected line: 0
  282. -- icon id / first selected line: 0 / 0
  283. -- text alignment: 0
  284. -- font id: 34
  285. -- text size: 12
  286. -- style flags: 0
  287. -- line height: 16
  288. -- part name: help
  289.  
  290.  
  291. -- part contents for background part 6
  292. ----- text -----
  293. Technical Information
  294.  
  295. -- part contents for card part 1
  296. ----- text -----
  297. This stack is arranged as follows:
  298.  
  299. Card 1
  300.      Card named "Intro", background named "Intro". Has a bunch of buttons, and is the only location of the
  301. stack dumping buttons.
  302.  
  303. Card 2
  304.      Card named "Journal Names", background named "Names". It contains one field holding the journal names for the journal button. Upon closing this card the journalList, the list of names the button displays, is remade.
  305.  
  306. Cards 3 through 11
  307.      The help cards. No card name, background named "Help". Usually just two fields: one line about the topic, and then a big field containing the information. Some cards contain example buttons that are usually disabled.
  308.  
  309. Card 12
  310.      This card exists only so the stack can tell where the reference cards begin. This is done only when the stack opens, so if you add more cards before this, the global variable firstRefCard, the number of the first card containing bibliography information, will not be correct. You will get a message about a button "Unix" not being found. To fix this, either leave the stack and return, or set firstRefCard by hand.
  311.  
  312. Cards 13 through the end.
  313.      These cards contain the bibliography data. There are 14 different backgrounds, but each had the same number of fields to avoid problems with find. Unused fields are stored on the right side of the card and should never have information put in them.
  314.  
  315.    Most of the interesting code is in the stack script. The script of the buttons on the left side of the card ("Card Type...", etc.) simply call the command in the stack script. This was done so that code changes occurred in only one place, instead of in 14 button scripts on 14 different backgrounds.
  316.    The makeBib command could easily be faster by moving subcommands up into higher level commands, such as putting the doLine code in authorLine, or putting the authorLine code in ArticleBib. If the time to write out the .bib file becomes intolerable, I will do that, but right now the code is flexible and easy to understand, and the delay doesn't bother me. You don't make .bib files too often, anyway.
  317.    If you create a new handler for a sytle of bibliography output that you need, you would modify the "makeBib" handler in the stack script.  Add your item to "bibList" so it will be displayed in the menu, and a few lines below that I indicate where your handler would be called.
  318.    
  319.    Special buttons for the technically sophisticated:
  320. For people who will actually muck around in the stack, I have included 3 buttons
  321. hidden behind this field. Don't pull them out unless you know what you are doing. As long as they are hidden, they are harmless.  Misused, they can destroy your stack. What they do:
  322.  
  323. "Make Distribution Stack": deletes all data cards except one of each type and hides the special buttons on this card.
  324.  
  325. Dump Bkgnd Field Data: goes to the bibliography backgound(s) of your choice and dumps all the information about the background fields to a text file. Written out in the form of pieces of field information ended by tabs, and separate field data separated by returns, this dumps *everything* about a field except its contents: name, rect, locktext, font, etc.
  326.  
  327. Remake Bkgnd Fields: this is the opposite of the previous button. Given a background (you can pick only one) and a file containing field data, this deletes all the background fields on that background and makes new fields using the data in the text file. The fields are created in the order they are read in.